﻿/// <reference name="MicrosoftAjax.js"/>
/// <reference path="aaagctrl.js" />
/// <reference path="SBT.debug.js" />

Type.registerNamespace("_05_NameScopes");

_05_NameScopes.ProcessItem = function() {
    _05_NameScopes.ProcessItem.initializeBase(this);
}

_05_NameScopes.ProcessItem.prototype = {
    get_data:function()
    {
        return this._data;
    },
    set_data:function(value)
    {
        this._data = value;
    },
    initialize: function() {
        this.set_mouseEnterAnimName("mouseEnter");
        this.set_mouseLeaveAnimName("mouseLeave");
        this.set_mouseUpAnimName("mouseUp");
        this.set_mouseDownAnimName("mouseDown");
        var txtBlock = this.get_element().findName("text");
        txtBlock.Text = this._data.Name;
        var txtBehavior = $create(SBT.AgBehavior,{plugin:this.get_plugin(), element:txtBlock},null,null,null);
        txtBehavior.setNamedValue(SBT.Grid.horizontalAlignment, SBT.HorizontalAlignment.center);
        txtBehavior.setNamedValue(SBT.Grid.verticalAlignment, SBT.VerticalAlignment.center);
        
        var bgBehavior = $create(SBT.AgBehavior,{plugin:this.get_plugin(), element:this.get_element().findName("back")},null,null,null);
        bgBehavior.setNamedValue(SBT.Grid.horizontalAlignment, SBT.HorizontalAlignment.stretch);
        bgBehavior.setNamedValue(SBT.Grid.verticalAlignment, SBT.VerticalAlignment.stretch);
        bgBehavior.setNamedValue(SBT.Grid.marginBottom,2);
        bgBehavior.setNamedValue(SBT.Grid.marginTop,2);
        bgBehavior.setNamedValue(SBT.Grid.marginLeft,5);
        bgBehavior.setNamedValue(SBT.Grid.marginRight,5);
        
        $create(SBT.Grid,{plugin:this.get_plugin(), element:this.get_element()},null,null,null);
        
        this._procDetailsName = this.get_plugin().Content.findName("procDetails_name");
        this._procDetailsPriority = this.get_plugin().Content.findName("procDetails_priority");
        this._procDetailsMemory = this.get_plugin().Content.findName("procDetails_memory");
        this._procDetailsSession = this.get_plugin().Content.findName("procDetails_session");
        
        _05_NameScopes.ProcessItem.callBaseMethod(this, 'initialize');
        this.add_click(Function.createDelegate(this, this.pushData));
        // Add custom initialization here
    },
    pushData:function(sender,args)
    {
        this._procDetailsName.Text = this._data.Name;
        this._procDetailsPriority.Text = this._data.Priority;
        this._procDetailsMemory.Text = Math.round(this._data.Memory / 1048576.0).toString()+" MB";
        this._procDetailsSession.Text = this._data.SessionID.toString();
    },
    dispose: function() {        
        //Add custom dispose actions here
        _05_NameScopes.ProcessItem.callBaseMethod(this, 'dispose');
    }
}
_05_NameScopes.ProcessItem.registerClass('_05_NameScopes.ProcessItem', SBT.Button);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
